{include file="../application/admin/view/header.html"}
</head>
<body>
<div class="container">
	<div class="row">
		<div class="col-md-12">
			<div class="alert kesn_prompt"></div>
		</div>

	</div>
	<div class="row">
	<form class="form-horizontal">
		{if condition="$action eq 'edit'"}
		<div class="form-group" style="display:none;">
	    <label for="id" class="col-sm-2 control-label">ID</label>
	    <div class="col-sm-10">
	      <input type="text" class="form-control" id="id" placeholder=""  value="{$task.id}"  >
	    </div> 
	  </div>
	  {/if}
	  <div class="form-group">
	    <label for="task" class="col-sm-2 control-label">任务</label>
	    <div class="col-sm-10">
	      <input type="text" class="form-control" id="task" placeholder="" {if condition="$action eq 'edit'"} value="{$task.task}" {/if} >
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="task_decr" class="col-sm-2 control-label">描述</label>
	    <div class="col-sm-10">
	      <input type="text" class="form-control" id="task_decr" placeholder="" {if condition="$action eq 'edit'"} value="{$task.task_decr}" {/if} />
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="exc_type" class="col-sm-2 control-label">执行类型</label>
	    <div class="col-sm-10">
	    	<select class="form-control select select-primary select-block mbl" id="exc_type" {if condition="$action eq 'edit'"} value="{$task.exc_type}" {/if} >
	    		<option value="0">-----</option>
			    <option value="1" {if condition="$action eq 'edit'"}{if condition="$task.exc_type eq '1'"} selected="selected" {/if}{/if}>定间隔执行</option>
			    <option value="2" {if condition="$action eq 'edit'"}{if condition="$task.exc_type eq '2'"} selected="selected" {/if}{/if}>定时执行</option>
			</select>
	    </div>
	</div>
     <div class="form-group" id="time_div" {if condition="$action eq 'add'"} style="display:none;" {/if} {if condition="$action eq 'edit'"}{if condition="$task.exc_type eq '2'"} style="display:block;" {else} style="display:none;" {/if}{/if}>
	    <label for="exc_time" class="col-sm-2 control-label">执行定时时间</label>
	    <div class="col-sm-10">
	      <input type="text" class="form-control" id="exc_time" placeholder="格式为英文输入法下的:mm-dd hh:ii,如：01-01 24:00 表示每年1月1日24时00分执行,00-00 24:00表示每日24时执行" {if condition="$action eq 'edit'"} value="{$task.exc_time}" {/if} >
	    </div>
	  </div>
	 <div class="form-group">
	    <label for="time" class="col-sm-2 control-label">间距时间</label>
	    <div class="input-group col-sm-3">
		  <input type="text" class="form-control col-sm-offset-1" placeholder="请输入秒数" id="time" {if condition="$action eq 'edit'"} value="{$task.time}" {/if} />
		  <span class="input-group-addon">秒</span>
		</div>
	  </div>
 
	</form>
 <button class="btn btn-primary save_task">保存</button>
</div>
</div>

{include file="../application/admin/view/footer.html"}
<script type="text/javascript">
	$('#exc_type').change(function(){
		var _this = $(this);
		if (_this.val() == '2') {
			$('#time_div').css('display','block');
		}else{
			$('#time_div').css('display','none');
		}
	});
</script>
<script type="text/javascript">
	$('.save_task').click(function(){
		var _this = $(this);
		var task_info = {};
		var task_id = $.trim($('#id').val());
		if (task_id != '') {
			task_info['id'] = task_id;
		}
		task_info['task'] = $.trim($('#task').val());
		task_info['task_decr'] = $.trim($('#task_decr').val());
		task_info['exc_type'] = $('#exc_type').val();
		if (task_info['exc_type'] == '2') {
			task_info['exc_time'] = $.trim($('#exc_time').val());
		}else{
			task_info['exc_time'] = '';
		}
		task_info['time'] = $.trim($('#time').val());
		$.ajax({
		      url: "save",    
		      dataType: "json",   
		      async: true, 
		      data: task_info,    
		      type: "POST",   
		      success: function(data) {
		        if (data.err == '0') {
		        	if (task_id == '') {
		        		_this.attr('disabled','disabled');
		        	}
		        	kesn_prompt('success',data.content);
		        }else{
		        	kesn_prompt('fail',data.content);
		        }
		      },
		     
		});

	});
</script>

</footer>
</body>
</html>
